﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FineSoft.Models
{
	public class CustomCode : Object
	{
		public override Class Type
		{
			get
			{
				return Class.Object;
			}
			set
			{
				base.Type = Class.Object;
			}
		}

		public string ValueCode;
		public string PreviewValueCode;

		public CustomCode()
		{
			this.Type = Class.Object;
		}

		public override string ConfigsString
		{
			get
			{
				return this.ValueCode;
			}
		}

		public override string ConfigsStringInEditor
		{
			get
			{
				if (string.IsNullOrEmpty(this.PreviewValueCode))
					return this.ValueCode;
				return this.PreviewValueCode;
			}
		}

		public CustomCode(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
			: base(info, context)
		{
			this.ValueCode = info.GetString("ValueCode");
			this.PreviewValueCode = info.GetString("PreviewValueCode");
		}

		public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
		{
			base.GetObjectData(info, context);
			info.AddValue("ValueCode", this.ValueCode);
			info.AddValue("PreviewValueCode", this.PreviewValueCode);
		}
	}
}